package router

import (
	"diff.wang/wdhealthcard/middleware"
	"diff.wang/wdhealthcard/service"
	"github.com/gin-gonic/gin"

	_ "diff.wang/wdhealthcard/docs" // swag init 产生的 docs
	swaggerfiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

func Router() *gin.Engine {

	r := gin.New()
	r.Use(gin.Recovery())
	r.Use(middleware.CorsMiddleware(), middleware.GinLogMiddleware())

	// 配置路由
	// swagger 配置
	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
	r.GET("/ping", service.PingServer)

	api := r.Group("/v1")
	{

		api.GET("/getToken", service.GetToken)
		api.POST("/ecard/regquery", service.EcardRegquery)
		api.POST("/ecard/apply", service.EcardApply)
		api.POST("/ecard/modify", service.EcardModify)
		api.POST("/ecard/bind", service.EcardBind)
		api.POST("/ecard/bindCards", service.EcardBindCards)
		api.POST("/ecard/refresh", service.EcardRefresh)
		api.POST("/ecard/accessOrgs", service.EcardAccessOrgs)
		api.POST("/ecard/useCardLog", service.EcardUseCardLog)
		api.POST("/ecard/verify", service.EcardVerify)
	}

	return r
}
